package index;

public class Student {
//构造方法  构造器
//空参构造方法
    public  Student(){
        System.out.println("空参构造运行了");
}
//带全部参数的构造方法;
public Student(int age,String gender,int id){
        this.age=age;
        this.gender=gender;
        this.id=id;
}

    //javaBean
    //不需要写main 方法
    //学生类 属性 方法
    private  int age; //年龄
   private String gender;//性别
   private int id; //id

   //针对每一个私有化的成员变量进行封装
    //对一个属性设置一个set()/get()
    public  void setAge(int age){
        if(age>0){
            this.age=age;
        }else{
            System.out.println("age error");
        }
    }
    public int getAge(){
        return  age;
    }
   //gender
    public void setGender(String gender){
        if(!gender.isEmpty()&&(gender.equals("男")||gender.equals("女"))){
            this.gender=gender;
        }else {
            System.out.println("gender error or gender is not allow empty");
        }
    }
   public String getGender(){
        return  gender;
   }
   //id
    public void setId(int id){
        if(id>0){
          this.id=id;
        }else {
            System.out.println("id error");
        }
    }
    public int getId(){
        return  id;
    }

    public void study(){
        System.out.println("study java");
    }


}
